package 牛客网_N.查找_递归_排序_贪心.search_insert_position;

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int target = Integer.parseInt(in.nextLine());
		String str = in.nextLine();
		String[] dataStr = str.split(" ");
		int[] A = new int[dataStr.length];
		for(int i = 0; i < dataStr.length; i++){
			A[i] = Integer.parseInt(dataStr[i]);
		}
		System.out.println(searchInsert(A, target));
	}

	/**
	 * 顺序查找
	 * @param A
	 * @param target
	 * @return
	 */
	public static int searchInsert(int[] A, int target) {
		for(int i = 0; i < A.length; i++){
			if(target <= A[i]) return i;
			if(target > A[i]){
				if(i == A.length-1) return A.length;
				if(target < A[i+1]) return i+1;
			}
		}
		return 0;
	}
	
	/**
	 * 二分查找
	 */
	public static int searchInsert2(int[] A, int target){
		int left = 0;
		int right = A.length-1;
		while(left <= right){
			int mid = (left+right)/2;
			if(A[mid] == target) return mid;
			else if (A[mid] < target) left = mid + 1;
			else right = mid - 1;
		}
		return left;
	}
}
